<template>
  <view class="box" v-if="cart.length">
      <my-address></my-address>
    <view class="textBox"> 
      <uni-icons type="shop-filled" size="18" class="imageIcon"></uni-icons>
      <text class="shopText">购物车</text>
    </view>

    <uni-swipe-action>
      <block v-for="(item,i) in cart" :key="i">
        <!--      {{item.goods_price}} -->
        <uni-swipe-action-item :right-options="options" @click=deleteItem(item.goods_id)>
          <my-goodsList :item="item" :showRadio=true :showNumber=true @radio-change="handlerRadio"
            @number-change="numberState"></my-goodsList>
        </uni-swipe-action-item>
      </block>
    </uni-swipe-action>
        <my-goods />
  </view>
  <view class="" v-else>
    <view class="imagebox">
      <image src="/static/image/空图片.jpg" ></image>
    </view>
  </view> 
</template>

<script>
  import badgeMix from "@/mixins/tabbar-badge.js"
  import {
    mapState,
    mapMutations
  } from "vuex"
  export default {
    mixins: [badgeMix],
    computed: {
      ...mapState("m_cart", ['cart']),

    },
    data() {
      return {
         options:[
                {
                    text: '删除',
                    style: {
                        backgroundColor: '#c00000'
                    }
                },
              ]
      }
    },
  
    methods: {
      ...mapMutations("m_cart", ['updataSatae', 'updataNumber','deleteListItem']),
      handlerRadio(e) {
        // console.log(e)
        // 把商品id和状态
        this.updataSatae(e)
      },

      numberState(e) {
        console.log(e)
        this.updataNumber(e)
      },
      deleteItem(id){
       
        this.deleteListItem(id)
       
      }
    },
  }
</script>

<style lang="scss">
  .box{
    padding-bottom: 50px;
  }
  .textBox {
    height: 40px;
    display: flex;
    padding-left: 5px;
    border-bottom: 1px solid #efefef;
    align-items: center;

    .imageIcon {}

    .shopText {
      font-size: 12px;
      margin-left: 10px;
    }
  }
  .imagebox{
    height: 560px;
  
    image{
      width: 100%;
      height: 100%;
    }
  }
</style>
